/**
 * 
 */
package t4j.innerclasses;

/**
 * @author sz
 *
 * create time：2012-9-19
 */
class Parcel4{
	private  class PContents implements Contents{
		private int i = 11;
		public int value(){return i;}
	}
	
	protected class PDestination implements Destination{ //包内可访问
		private String label;
		private PDestination(String whereTo){
			label = whereTo;
		}
		public String readLabel(){
			return label;
		}
	}
	
	private class LContents implements Contents{

		private int i;
		
		private LContents(int i){
			this.i = i ;
		}
	
		public int value() {return i;}
		
	}
	
	public Contents contents(){
		return new PContents();
	}
	
	public Destination destination(String s){
		return new PDestination(s);//外部类可以访问内部类的PRIVATE构造函数
	}
	
	public int getLContents(){
		return new LContents(5).i;//外部类可以访问内部类的PRIVATE方法和变量
	}
}


public class TestParcel {
	public static void main(String[] args) {
		Parcel4 p = new Parcel4();
		
		Contents c = p.contents();
		Destination d = p.destination("Tasmaina");
		
	
		
		System.out.println(p.getLContents());
		
		//! error Destination pd = p.new PDestination("Tasmaina"); //因为构造函数PRIVATE缘故
	}
}
